using System;
using System.Collections.Generic;
using System.Reflection;
using Lockstep.Game;
using UnityEngine;

namespace Lockstep.Game {
    public class GameResourceService : BaseGameService, IGameResourceService {
        public string pathPrefix = "Prefabs/";

        private Dictionary<int, GameObject> _id2Prefab = new Dictionary<int, GameObject>();

        public object LoadPrefab(int id){
            return _LoadPrefab(id);
        }

        public object LoadMapItem(WallCellConfig info) {
            return info.prefab;
        }
        public object LoadBullet(BulletConfig info) {
            return info.prefab;
        }
        GameObject _LoadPrefab(int id){
            if (_id2Prefab.TryGetValue(id, out var val)) {
                return val;
            }

            var config = _gameConfigService.GetEntityConfig(id);
            _id2Prefab[id] = config.prefab;
            return config.prefab;
        }
    }
}